<%--
  User: ssl
  Date: 2018-4-2
  Time: 15:40
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/commons/taglibs.jsp" %>
<html>
<head>
    <title>RMS管理系统</title>
    <!-- 导入公用css -->
    <%@ include file="/WEB-INF/views/commons/headcss.jsp" %>
    <!-- 导入公用js -->
    <%@ include file="/WEB-INF/views/commons/headjs.jsp" %>

</head>
<!-- 设置currentHref -->
<c:set var="currentHref" value="/sys/user"></c:set>
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow: hidden">
<div id="wrapper">
    <!--左侧导航开始-->
    <%@ include file="/WEB-INF/views/commons/menu.jsp" %>
    <!--左侧导航结束-->
    <!--右侧部分开始-->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <div class="row border-bottom">
            <!-- 页面头部 -->
            <%@ include file="/WEB-INF/views/commons/header.jsp" %>
        </div>
        <div class="row J_mainContent" id="content-main" style="overflow: auto">
            <div class="wrapper wrapper-content animated fadeInRight">
                <div class="col-sm-12">
                    <!-- 此处填充页面内容 -->
                    <div class="iboxtitle">
                        <span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;用户列表</span>
                    </div>
                    <!-- 查询条件 -->
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
                                <div class="row">
                                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                                        <label>客户名：</label>
                                        <input type="text" placeholder="客户名" id="customerName"
                                               name="customerName" class="form-control">
                                    </div>
                                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                                        <label>业务员：</label>
                                        <input type="text" placeholder="业务员" id="salesmanName"
                                               name="salesmanName" class="form-control">
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
                                <button class="zhixcx" type="button" onclick="query();">执行查询</button>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 查询条件end -->
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                            <div class="jqGrid_wrapper">
                                <!-- table -->
                                <table id="table_list_1"></table>
                                <!-- table end -->
                                <div id="pager_list_1"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--右侧部分结束-->
</div>
<!-- create model -->
<div class="modal fade" id="createModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content"></div>
    </div>
</div>
<!-- create model end -->
<!-- update model -->
<div class="modal fade" id="updateModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content"></div>
    </div>
</div>
<!-- update model end -->
<!-- 加载全局js -->
<%@ include file="/WEB-INF/views/commons/foot.jsp" %>
</body>
<script>
    //jqgrid参考手册：http://blog.mn886.net/jqGrid/
    //示例参考：https://www.cnblogs.com/lgq880821/p/6073070.html
    $(function () {
        // 填充表格，分页
        getData();
    });
    var getData = function () {
        $.jgrid.defaults.styleUI = 'Bootstrap';
        $("#table_list_1").jqGrid({
            url: "${ctx}/sys/user/list",
            datatype: "json",
            colNames: ['主键', '创建时间', '姓名', '邮箱', '手机号', '部门', '状态'],
            colModel: [
                {name: 'id', index: 'id', hidden: true},
                {name: 'createDate', index: 'createDate', align: 'center'},
                {name: 'userName', index: 'userName', align: 'center'},
                {name: 'email', index: 'email', align: 'center'},
                {name: 'mobile', index: 'mobile', align: 'center'},
                {name: 'deptId', index: 'deptId', align: 'center'},
                {name: 'status', index: 'status', align: 'center',
                    formatter: function (cellvalue, options, cell) {
                                if ("1"==cellvalue){
                                    return "有效";
                                }else {
                                    return "无效";
                                }
                            }
                },
            ],
            mtype: "post",
            rownumbers: true,//显示序号
            hidegrid: true, //是否隐藏grid控件
            sortname:"createDate",//默认的排序字段
            sortorder:"asc",//默认的排序方式
            autowidth: true,//自动调整列宽
            shrinkToFit:true,
            forceFit:true,
            rowNum: 10,
            rowList: [10, 20, 25],
            viewrecords: true,//是否显示总记录数。
            caption: "用户列表",
            pager: "#pager_list_1",
            hidegrid: true,
            multiselect: false,
            altRows: true,
            altclass: 'someClass',
            ondblClickRow: function (rowId) {
                //双击触发的事件
                layer.msg('正在进入，请稍后...', {icon: 16});
                var row = $("#table_list_1").jqGrid("getRowData", rowId);
                //alert(row.id);
            },
            jsonReader: {
                root: "data.list",//data数据
                page: "data.pageNum",//当前页
                total: "data.pages",//总页数
                records: "data.size",//查询出的记录数
                repeatitems: false,
                id: "id"
            }
        })
    }
</script>
<script>
    // create
    function openCreateModel() {
        $('#createModel').modal({
            remote: "${ctx}/sys/menu/create?id="
        })
        ;
    }
    // detail
    function openDetailModel() {
        $('#detailModel').modal({
            remote: "${ctx}/sys/menu/detail"
        });
    }
    // update
    function openUpdateModel() {
        $('#updateModel').modal({
            remote: "${ctx}/sys/menu/update/"
        });
    }
    // deleted
    function deleted() {
        var url = "${ctx}/sys/menu/delete/";
        var result = rmsAjax(url, false, "POST", "");
        if (!!result) {
            if ("1" == result.code) {
                notify("成功", "删除成功", "success");
                window.location.href = "${ctx}/sys/menu";
            } else {
                notify("错误", result.msg, "error");
            }
        } else {
            return;
        }
    }
</script>
</html>

